//
//  PersonalSettingPolicyController.m
//  ChatForHot
//
//  Created by wr on 2018/10/17.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "PersonalSettingPolicyController.h"

@interface PersonalSettingPolicyController ()

@property (nonatomic,strong) UITextView *HOTCHATPolicyTextView;
@end

@implementation PersonalSettingPolicyController

- (void)HOTCHATdidInitialized {
    [super HOTCHATdidInitialized];
}

- (void)HOTCHATInsertSubViews {
    
    self.HOTCHATPolicyTextView = [[UITextView alloc] init];
    self.HOTCHATPolicyTextView.editable = NO;
    self.HOTCHATPolicyTextView.selectable = NO;
    if (@available(iOS 11.0, *)) {
        self.HOTCHATPolicyTextView.contentInsetAdjustmentBehavior = UIApplicationBackgroundFetchIntervalNever;
    } else {}
    [self.view addSubview:self.HOTCHATPolicyTextView];
    [self HOTCHATLoadTextFile];
}

- (void)HOTCHATsetNavigationItemsIsInEditMode:(BOOL)isInEditMode animated:(BOOL)animated {
    [super HOTCHATsetNavigationItemsIsInEditMode:isInEditMode animated:animated];
    
    self.title = NSLocalizedString(@"personS4", nil);
}

- (void)HOTCHATLoadTextFile {
    NSString *path = [[NSBundle mainBundle] pathForResource:@"Policy-English" ofType:@"txt"];
    NSError *error = nil;
    NSString *str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
    if (str.length > 0) {
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:str];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
        paragraphStyle.lineSpacing = 5.0;
        NSDictionary *attrsDictionary1 = @{NSFontAttributeName:[UIFont systemFontOfSize:14],
                                           NSParagraphStyleAttributeName:paragraphStyle,
                                           NSForegroundColorAttributeName:HOTCHATrgb(26, 26, 26)};
        [attributedString addAttributes:attrsDictionary1 range:NSMakeRange(0, str.length)];
        NSMutableParagraphStyle *paragraphStyle2 = [[NSMutableParagraphStyle alloc] init];
        paragraphStyle2.lineSpacing = 3;
        self.HOTCHATPolicyTextView.attributedText = attributedString;
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    [self.HOTCHATPolicyTextView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(14);
        make.left.equalTo(self.view).offset(14);
        make.bottom.equalTo(self.view).offset(-14);
        make.right.equalTo(self.view).offset(-14);
    }];
}
@end
